package com.zmn.oms.dubbo.impl.zmn.third.taobao;

import org.apache.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.common.utils.validator.ValidateResult;
import com.zmn.common.utils.validator.ValidatorUtil;
import com.zmn.oms.common.constant.OrderConsts;
import com.zmn.oms.dubbo.dto.zmn.third.taobao.MasterAbilityDRO;
import com.zmn.oms.dubbo.dto.zmn.third.taobao.MasterInfoDIO;
import com.zmn.oms.dubbo.dto.zmn.third.taobao.MasterTagsDRO;
import com.zmn.oms.dubbo.interfaces.zmn.third.taobao.TaoBaoRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.third.taobao.TaobaoTmcConstants;
import com.zmn.oms.third.taobao.dto.WorkerAbilityDTO;
import com.zmn.oms.third.taobao.dto.WorkerInfoDTO;
import com.zmn.oms.third.taobao.dto.WorkerTagsDTO;
import com.zmn.oms.third.taobao.service.TmallService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 天猫接口
 * 获取工程师标签接口
 *
 * @author: yule
 * @since: 2020/04/24 12:38
 **/
@Service(loadbalance = "roundrobin", timeout = 10000, version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class TaoBaoRemoteServiceImpl implements TaoBaoRemoteService {

    static final String TAG = "天猫";

    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    TmallService tmallService;

    @Override
    public ResponseDTO<List<MasterTagsDRO>> getMasterTagListByMasterInfo(List<MasterInfoDIO> masterInfos) {
        ValidateResult validateResult = ValidatorUtil.validator(masterInfos);
        if (!validateResult.isSuccess()) {
            logger.error("[{}] 参数错误：{}", TAG, validateResult.toString());
            return ResponseDTO.fail("提交参数错误：" + validateResult.toString());
        }
        //组装工程师标签信息
        List<MasterTagsDRO> masterTagsList = Lists.newArrayList();
        logger.info("【{}】主动拉取工人标签数据返回List<MasterTagsDRO>:[{}]", TaobaoTmcConstants.NAME_TMALL, JSON.toJSON(masterTagsList));
        return ResponseDTO.success(masterTagsList);
    }

}
